<template>
    <view class="content">
        <tab ref="tab" @tabChange="tabChange" :list="list" :stickyTop="0"></tab>
        <view class="record-list">
            <record-item v-for="(recordItem, recordIndex) in list[active].goodsList" :key="recordIndex" :recordItem="recordItem"></record-item>
            <!-- 加载中插件 -->
            <load-more
                :loading="list[active].loading"
                :finished="list[active].finished"
                :empty="list[active].empty"
				emptyType="record"
                emptyText="暂无记录~"
            ></load-more>
        </view>

        <!--回到顶部-->
        <view class="scrollTop" :class="[{ show: isShowScrollTop }]" @tap="backTop">
            <text class="iconfont icon-huidaodingbu"></text>
        </view>

        <!--智能搜索-->
        <ai-search ref="aiSearch"></ai-search>
    </view>
</template>

<script>
	import loader from '@/utils/mixin/loader';
	import LoadMore from '@/components/LoadMore'
    import RecordItem from '@/components/member/RecordItem'
    import Tab from '@/components/uni/Tab'
	export default {
		name: 'record',
        components: {
			RecordItem,
			LoadMore,
			Tab
        },
		mixins: [loader],
		data() {
			return {

            };
		},
		onLoad() {
			this.init();
		},
        onShow() {
			this.$nextTick(() => {
			uni.getClipboardData({
				success: res => {
					if (res.data && this.$store.state.common.aiSearch) {
						this.$refs.aiSearch.open(res.data);
						this.$store.commit({
							type: 'setAiSearch',
							aiSearch: false
						});
					}
				}
			});
		});
        },
		onHide() {
			this.$refs.aiSearch.close();
		},
		methods: {
			// 页面初始化
			init() {
				// 获取&创建一级分类
				let arr = [{ label: '全部' }, { label: '审核中' }, { label: '已通过' }, { label: '已提现' }, { label: '已驳回' }, { label: '提现失败' }];
				arr.forEach(item => {
					item.loading = false;
					item.finished = false;
					item.empty = false;
					item.page = 1;
					item.goodsList = [];
                });
				this.list = arr;
				this.loadMore(this.list[0]);
			},
			// 加载前参数处理
			beforeLoad() {
				if (this.active === 1) {
					this.params.status = 0;
				} else if (this.active === 2) {
					this.params.status = 1;
				} else if (this.active === 3) {
					this.params.status = 3;
				} else if (this.active === 4) {
					this.params.status = 2;
				} else if (this.active === 5) {
					this.params.status = 4;
				} else {
					delete this.params.status;
				}

				this.service = this.$service.member.withdraw.page(this.params);
				return true;
			}
		}
	}
</script>

<style lang="scss" scoped>
    .content {
        background: #f6f7fa;
       min-height: 100vh;
        .record-list {
            padding-bottom: 30rpx;
        }
    }
</style>
